package com.beyondbit.hr.report.support.render;

import com.beyondbit.hr.report.support.ReportConverter;
import net.sf.jasperreports.engine.JRParameter;
import net.sf.jasperreports.engine.export.HtmlExporter;
import net.sf.jasperreports.export.*;
import org.springframework.http.MediaType;

import java.io.OutputStream;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

public class HTMLRender extends AbstractRender<HtmlExporter> {
    @Override
    public HtmlExporter exporter() {
        HtmlExporter htmlExporter = new HtmlExporter();
        return htmlExporter;
    }

    @Override
    public ExporterConfiguration defaultExporterConfiguration() {
        SimpleHtmlExporterConfiguration htmlExporterConfiguration = new SimpleHtmlExporterConfiguration();
        return htmlExporterConfiguration;
    }

    @Override
    public List<MediaType> getSupportedMediaTypes() {
        return Arrays.asList(ReportConverter.HTML);
    }

    @Override
    public Map<String, Object> defaultReportSettings() {
        Map<String, Object> m =  super.defaultReportSettings();
        m.put(JRParameter.IS_IGNORE_PAGINATION, true);
        return m;
    }

    @Override
    public ExporterOutput exporterOutput(OutputStream outputStream) {
        return new SimpleHtmlExporterOutput(outputStream);
    }
}
